﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Product_Provider
    {
        [Description("ID")]
            public long ID{get;set;}
        [Description("Mã")]
            public string Code{get;set;}
        [Description("Tên")]
            public string Name{get;set;}
        [Description("Địa chỉ")]
            public string Address{get;set;}
        [Description("Email")]
            public string Email{get;set;}
        [Description("Điện thoại")]
            public string Phone{get;set;}
        [Description("Mã số thuế")]
            public string TaxCode{get;set;}
        [Description("Sử dụng")]
            public bool Active{get;set;}
         
        public Product_Provider()
        {       
                            Code ="";   
                            Name ="";   
                            Address ="";   
                            Email ="";   
                            Phone ="";   
                            TaxCode ="";   
                          //  Contact ="";   
        }
        
       static Product_Provider DynamicCast<T>(object row_data, object row_header) where T : Product_Provider
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Product_Provider ret = new Product_Provider();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "Code":
                        ret.Code = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Name":
                        ret.Name = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Address":
                        ret.Address = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Email":
                        ret.Email = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Phone":
                        ret.Phone = ConvertObject.ToString(dt[column]);
                       break;
                      case  "TaxCode":
                        ret.TaxCode = ConvertObject.ToString(dt[column]);
                       break;
                      //case  "Contact":
                      //  ret.Contact = ConvertObject.ToString(dt[column]);
                      // break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
